﻿package com.tudou.log
{
    import flash.utils.*;

    public class TudouLogger extends Object
    {
        public static const LEVEL_WARN:Number = 2;
        public static var level:Number = 1;
        public static const LEVEL_ERROR:Number = 3;
        private static var logList:Dictionary = new Dictionary();
        private static var logClassList:Array = new Array();
        public static const LEVEL_NONE:Number = 4;
        public static const LEVEL_DEBUG:Number = 1;

        public function TudouLogger()
        {
            return;
        }// end function

        public static function addLogger(param1:ILogger) : void
        {
            var _loc_2:* = getQualifiedClassName(param1);
            var _loc_3:* = getDefinitionByName(_loc_2) as Class;
            if (logList[_loc_3] == null)
            {
                logList[_loc_3] = param1;
            }
            return;
        }// end function

        public static function debug(param1:Object, ... args) : void
        {
            if (level <= LEVEL_DEBUG)
            {
                print("debug", param1, args);
            }
            return;
        }// end function

        public static function error(param1:Object, ... args) : void
        {
            if (level <= LEVEL_ERROR)
            {
                print("error", param1, args);
            }
            return;
        }// end function

        private static function print(param1:String, param2:Object, param3:Array) : void
        {
            var _loc_5:ILogger = null;
            var _loc_6:Function = null;
            var _loc_4:* = getQualifiedClassName(param2);
            if (logClassList.indexOf(_loc_4) == -1)
            {
                return;
            }
            param3.unshift(param2);
            for each (_loc_5 in logList)
            {
                
                _loc_6 = _loc_5[param1];
                _loc_6.apply(_loc_5, param3);
            }
            return;
        }// end function

        public static function addLogClass(param1:Object) : void
        {
            var _loc_2:String = null;
            if (param1)
            {
                _loc_2 = getQualifiedClassName(param1);
                logClassList.push(_loc_2);
            }
            return;
        }// end function

        public static function warn(param1:Object, ... args) : void
        {
            if (level <= LEVEL_WARN)
            {
                print("warn", param1, args);
            }
            return;
        }// end function

    }
}
